//
//  New3ViewController.m
//  A_HandHeldLOL
//
//  Created by Zhao YanBin on 16/1/19.
//  Copyright © 2016年 zhaoyanbin. All rights reserved.
//

#import "New3ViewController.h"
#import "NewTableViewCell.h"
#import "AFNModel.h"
#import "New3Model.h"
#import <UIImageView+WebCache.h>
#import "NewModel.h"
@interface New3ViewController ()<UITableViewDelegate,UITableViewDataSource>
@property(nonatomic, retain)UITableView *tableViewTwo;
@property(nonatomic, retain)NSMutableArray *array;
@end

@implementation New3ViewController

-(void)dealloc
{
    [self.tableViewTwo release];
    [self.array release];
    [super dealloc];
}
-(instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        self.tableViewTwo = [[UITableView alloc] initWithFrame:CGRectMake(0, -20, self.view.frame.size.width, self.view.frame.size.height  - 64 - 49 ) style:UITableViewStylePlain];
        _tableViewTwo.dataSource = self;
        _tableViewTwo.delegate = self;
        [_tableViewTwo registerClass:[NewTableViewCell class] forCellReuseIdentifier:@"cell4"];
        self.automaticallyAdjustsScrollViewInsets = NO;
    }
    return self;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
}
- (UITableView *)setWithStr:(NSString *)str
{
    [AFNModel GETWithURL:str completion:^(id result) {
        self.array = result[@"list"];
        self.array = [NewModel modelHanderWithArray:_array];
        [self.tableViewTwo reloadData];
    }];
    return _tableViewTwo;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return _array.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NewTableViewCell *cell2 = [tableView dequeueReusableCellWithIdentifier:@"cell4" forIndexPath:indexPath];
    NewModel *d = _array[indexPath.row];
    cell2.title.text = d.title;
    cell2.subhead.text = d.summary;
    [cell2.imgView sd_setImageWithURL:[NSURL URLWithString:d.image_url_small]];
    return cell2;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(nonnull NSIndexPath *)indexPath
{
    return 100;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
